package by.grsu.perovskij.page;

import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.spring.injection.annot.SpringBean;

import by.grsu.perovskij.dao.BillDao;
import by.grsu.perovskij.entity.Bill;

@SuppressWarnings("serial")
public class ListBillsPage extends BasePage {

	@SpringBean
	private BillDao billDao;

	public ListBillsPage() {
		super();

		final List<Bill> bills = billDao.findAll();

		add(new ListView<Bill>("list", bills) {
			@Override
			protected void populateItem(final ListItem<Bill> item) {
				final Bill bill = item.getModelObject();
				item.add(new Label("passenger", bill.getPassenger()
						.getSecondName()));
				item.add(new Label("route", bill.getScheduleRecord().getName()));
				item.add(new Label("cost", String.valueOf(bill.getCost())));
				/*
				 * item.add(new Link<Bill>("editLink",new Model<Bill>(request)){
				 * 
				 * @Override public void onClick(){ setResponsePage(new
				 * EditTicketRequest(request)); } });
				 */
			}
		});
		/*
		 * add(new Link<Bill>("createLink", new Model<Bill>(new Bill())) {
		 * 
		 * @Override public void onClick() { setResponsePage(new
		 * EditBill(getModelObject())); } });
		 */
	}
}
